unit Forms.CustomSimpleForm;

interface

uses
  System.SysUtils, Vcl.Forms;

type
  TCustomSimpleForm = class(TForm)
  public
    constructor Create; reintroduce;
    class function GetInstance: TCustomSimpleForm;
  end;

implementation

{$R *.dfm}

{ TCustomSimpleForm }

constructor TCustomSimpleForm.Create;
begin
  raise Exception.Create('Please, use the class method GetInstance.');
end;

class function TCustomSimpleForm.GetInstance: TCustomSimpleForm;
var
  nI: Integer;
begin
  result := nil;
  for nI := 0 to Pred(Screen.FormCount) do
    if Screen.Forms[nI] is Self then
      begin
        result := Screen.Forms[nI] as Self;
        Break;
      end;
  if result = nil then
    result := inherited Create(nil);
end;

end.

